import { ORDER_LIST_DATA } from '../actions/actionsTypes';

const initState = {
  list: []
}

const getOrderList = (state, action) => {
  let page = action.obj.page;

  if(page == 0) {
    return {...state,  list: action.obj.list}
  } else {
    let beforeList = state.list;
    return {...state,  list: action.obj.list.concat(beforeList)}
  }
}


const getOrderListReducer = (state = initState, action) => {
  switch(action.type) {
    case ORDER_LIST_DATA:
      return getOrderList(state, action);
    default: 
      return state;
  }
}

export default getOrderListReducer;
